package cn.compayname.web;

import cn.compayname.pojo.Account;
import cn.compayname.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/account")
public class AccoutnAction {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/getAll")
    public ModelAndView findAllAccounts() throws Exception {
        ModelAndView result = new ModelAndView();
        List<Account> list = accountService.findAllAccounts();
        result.addObject("accounts", list);
        result.setViewName("account_list");
        return result;
    }

}
